<template>
  <div class="mui-pages">
    <header class="mui-bar mui-bar-nav">
      <div class="header-common-title flex-justify-start">
        <div @click="fn.back()" class="mui-action-back">
          <img class="back-btn" src="../../../../static/images/back.png" />
        </div>
        <div v-if="!approval" class="header-search flex-center">
          党员学习未答说明申请
        </div>
        <div v-if="approval" class="header-search flex-center">
          党员学习未答说明审批
        </div>
      </div>
    </header>
    <div class="mui-page-content">
      <div class="mui-scroll-wrapper">
        <div class="mui-scroll-wrapper work-message-lists">
          <cube-scroll
            ref="scroll"
            :options="options"
            @pulling-up="onPullingUp"
          >
            <cube-swipe>
              <transition-group name="swipe" tag="div">
                <div v-for="(data, index) in swipeData" :key="data.id">
                  <div @click="detail(data)">
                    <p class="history-message flex-center">
                      {{ data.createTime }}
                    </p>
                    <div class="work-message-item">
                      <div class="work-message-item-title">
                        <p class="schedule-item-world">
                          <b>试卷名称：</b>{{ data.paperName }}
                        </p>
                        <p class="schedule-item-world">
                          <b>申请人员：</b>{{ data.dangYuanName }}
                        </p>
                        <p class="schedule-item-world">
                          <b>所属支部：</b>{{ data.partyGroupName }}
                        </p>
                        <p v-if="approval" class="schedule-item-world">
                          <b>审批结果：</b>
                          <span
                            v-if="data.result === '0'"
                            class="mine-lists-money"
                            >不同意</span
                          >
                          <span v-if="data.result === '1'" class="work-blue"
                            >已同意</span
                          >
                        </p>
                      </div>
                      <div class="flex-between-center message-details">
                        <p>查看详情</p>
                        <span class="mui-icon mui-icon-arrowright"></span>
                      </div>
                    </div>
                  </div>
                </div>
              </transition-group>
            </cube-swipe>
            <!-- <div class="text-center no-data" v-if="swipeData.length === 0">
              <img src="../../../../static/images/no_data.png" alt="" />
              <p>暂无数据</p>
            </div> -->
            <!-- W noData -->
            <noData v-if="swipeData.length === 0"></noData>
            <onBottom v-else-if="onBottom"></onBottom>
          </cube-scroll>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import tools from "@/utils/tools";
import loginService from "@/service/loginService";
export default {
  name: "noanswerApprove",
  data() {
    return {
      fn: tools,
      options: {
        pullUpLoad: true,
        scrollbar: false,
      },
      onBottom: false, // W onBottom
      objectsName: "",
      swipeData: [],
      infinite: true,
      pageIndex: 0,
      pageSize: 20,
      approval: false,
    };
  },
  created() {
    // this.answerSituationItem = this.$store.state.answerSituationItem
    this.loadData();
  },
  methods: {
    detail(data) {
      this.$router.push({ path: `/noanswerApplyDetails/${data.id}` });
    },
    loadData() {
      this.flag = this.$route.params.flag;
      let spStatus = "0";
      if (this.flag === "1") {
        spStatus = "0";
        this.approval = false;
      } else if (this.flag === "2") {
        spStatus = "12";
        this.approval = true;
      }
      let data = {
        pageIndex: this.pageIndex,
        pageSize: this.pageSize,
        sortField: "createTime",
        sortOrder: "DESC",
        spStatus: spStatus,
      };
      loginService.getNoAnswerRequestRecordList(data).then((res) => {
        if (res.code === 200 && res.data.length < 1) {
          this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate();
          return tools.tip("已无更多数据");
        }
        this.pageIndex++;
        this.swipeData = this.swipeData.concat(res.data);
        setTimeout(() => {
          this.$refs.scroll.forceUpdate &&
            this.$refs.scroll.forceUpdate(true, false);
          this.options.isPullUpLoad = false;
        }, 100);
      });
    },
    go(item) {
      // // 保存此条信息
      // this.$store.state.answerSituationItem = item
      this.$router.push({ path: "/noanswerApplyDetails" });
    },
    onPullingUp() {
      console.log("onPullingUp");
      this.loadData();
    },
  },
};
</script>

<style scoped>
</style>
